package com.itheima.tlias.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 *
 * @PROJECT_NAME: tlias-web-management
 * @DESCRIPTION:
 * @USER: Administrator
 * @DATE: 2023/4/13 9:44
 */
@Component
@Slf4j
//@Aspect
public class TimesApect {
    @Pointcut("execution(* com.itheima.tlias.service.impl.*.*(..))")
    public void pt(){}
    //增强
    @Around("pt()")
    private Object aeoundMethod(ProceedingJoinPoint pjp) {
        try {
            long start = System.currentTimeMillis();
            Object result = pjp.proceed();
            long end = System.currentTimeMillis();
            System.out.println("方法执行了" + (end - start) + "ms");
            return result;
        }catch (Throwable e){
            e.printStackTrace();
        }
        return null;
    }
}
